package cn.zhfeat.utils;

import java.util.Comparator;
import java.util.Map;

/**
 * @explain 排序类
 * @author zhanghao
 * @date 2017年10月17日
 */
@SuppressWarnings("unchecked")
public class ComparatorList implements Comparator{

	  
    private String compareStr;  
      
    public ComparatorList(){  
          
    }  
      
    public ComparatorList(String compareStr){  
       this.compareStr=compareStr;  
    }

    @Override  
    public int compare(Object o1, Object o2) {  
        int flag2=0;  
        Map map1=(Map)o1;  
        Map map2=(Map)o2;  
        int flag=String.valueOf(map1.get(compareStr)).compareTo(String.valueOf(map2.get(compareStr)));  
          
        //倒序  
        if(flag>0){  
            flag2=1;  
        }else if(flag<0){  
            flag2=-1;  
        }  
        return flag2;  
    }        
   
}
